package com.cheng.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.cheng.domain.Customer;


public interface CustomerRespository extends JpaRepository<Customer, Integer> {

	List<Customer> findByFixedAreaIdIsNull();

	List<Customer> findByFixedAreaId(String fixedareaid);

	@Query("update Customer set fixedAreaId = null where fixedAreaId = ?")
	@Modifying
	public void clearFixedareaid(String fixedareaid);
	
	@Query("update Customer set fixedAreaId = ? where id = ?")
	@Modifying
	public void associationCustomer(String fixedareaid,Integer id);

	Customer getByTelephone(String telephone);

	@Query("update Customer set type = 1 where telephone = ?")
	@Modifying
	void updataCustomer(String telephone);
	
	@Query("select fixedAreaId from Customer where address = ? and id = ?")
	String findFixedareaByaddress(String address,Integer id);
	
}
